﻿using Quartz;
using Quartz.Impl;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DuibaRefreshStateService
{
    class Program
    {
        private readonly static string StrCron = ConfigurationManager.AppSettings["cron"] == null ? "* 10 * * * ?" : ConfigurationManager.AppSettings["cron"];

        static void Main(string[] args)
        {
            Console.WriteLine("兑吧订单状态定时同步服务\n{0}",DateTime.Now.ToString("r"));
            //1.首先创建一个作业调度池
            ISchedulerFactory schedf = new StdSchedulerFactory();
            IScheduler sched = schedf.GetScheduler();
            //2.创建出来一个具体的作业
            IJobDetail job = JobBuilder.Create<DuibaJob>().Build();
            //3.创建并配置一个触发器
            ITrigger trigger = TriggerBuilder.Create().StartNow().WithCronSchedule(StrCron).Build();
            //4.加入作业调度池中
            sched.ScheduleJob(job, trigger);
            //5.开始运行
            sched.Start();

            Console.WriteLine("任务正在执行，按任意键退出。。。。");
            Console.ReadKey();
        }
    }
}
